<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>码流水管理</title>
    <link rel="stylesheet" href="common/js/file-input/fileinput.css">
    <link rel="stylesheet" href="common/css/switchery/style.css">
    <link rel="stylesheet" href="common/css/bootstrap.css">
    <link rel="stylesheet" href="common/css/font-awesome.min.css">
    <link rel="stylesheet" href="common/css/style.css">
    <link rel="stylesheet" href="common/css/plugin.css">
    <link rel="stylesheet" href="common/js/datepicker/bootstrap-datetimepicker.css">
    <script src="common/js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="common/js/ie/respond.min.js"></script>
    <script src="common/js/ie/html5.js"></script>
</head>
<body onload="initTab()">

<section class="main padder">
    <div class="clearfix">
        <h4><i class="icon-list"></i> 码流水列表</h4>
    </div>
    <section class="panel">
        <div class="tab-content">
            <div id="fama" class="tab-pane fade active in">
                <form id="queryOrderPage" action="queryOrderPage" class="form-horizontal">
                    <input type="hidden" name="storeId"/>
                    <input type="hidden" name="activityId"/>

                    <div class="form-group">
                        <div class="col-lg-12">
                            <div class="col-lg-1 control-label">开始日期</div>
                            <div class="col-lg-2">
                                <input id="startTime" tabindex="11" data-parsley-trigger="change" readonly="readonly"
                                       class="input-small form-control datetimepicker" data-parsley-required="true"
                                       placeholder="开始时间" type="text"
                                       value="" size="16" name="startTime">
                            </div>
                            <div class="col-lg-1 control-label">结束日期</div>
                            <div class="col-lg-2">
                                <input id="endTime" tabindex="12" data-parsley-trigger="change" readonly="readonly"
                                       class="input-small form-control datetimepicker" data-parsley-required="true"
                                       placeholder="结束时间" type="text"
                                       value="" size="16" name="endTime">
                            </div>
                            <div class="col-lg-1 control-label">操作类型</div>
                            <div class="col-lg-1">
                                <input type="checkbox" name="statusList" value="0">
                                消费
                            </div>
                            <div class="col-lg-1">
                                <input type="checkbox" name="statusList" value="2">
                                撤消
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-12">
                            <div class="col-lg-1 control-label">活动名称</div>
                            <div class="col-lg-2">
                                <input type="text" readonly="readonly" tabindex="1"
                                       class="form-control input-small parsley-validated"
                                       placeholder="请输入活动名称" data-parsley-maxlength="30"
                                       name="activityName">
                            </div>
                            <div class="col-lg-1 control-label">设备号</div>
                            <div class="col-lg-2">
                                <input type="text" tabindex="1" class="form-control input-small parsley-validated"
                                       placeholder="请输设备号" data-parsley-maxlength="30"
                                       name="enCode">
                            </div>
                            <div class="col-lg-1 control-label">门店名称</div>
                            <div class="col-lg-2">
                                <input type="text" readonly="readonly" tabindex="1"
                                       class="form-control input-small parsley-validated"
                                       placeholder="门店名称" data-parsley-maxlength="30"
                                       name="storeName">
                            </div>
                            <div class="col-lg-1 control-label">订单号</div>
                            <div class="col-lg-2">
                                <input type="text" tabindex="1" class="form-control input-small parsley-validated"
                                       placeholder="订单号" data-parsley-maxlength="30"
                                       name="orderNo">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-12">
                            <div class="col-lg-1 control-label">企业名称</div>
                            <div class="col-lg-2">
                                <input type="text" tabindex="1" class="form-control input-small parsley-validated"
                                       placeholder="请输入企业名称" data-parsley-maxlength="30"
                                       name="enterpriseName">
                            </div>
                            <div class="col-lg-1 control-label">手机号</div>
                            <div class="col-lg-2">
                                <input type="text" tabindex="1" class="form-control input-small parsley-validated"
                                       placeholder="请输入手机号" data-parsley-maxlength="30"
                                       name="mobile">
                            </div>
                            <div class="col-lg-1 control-label">兑换码</div>
                            <div class="col-lg-2">
                                <input type="text" tabindex="1" class="form-control input-small parsley-validated"
                                       placeholder="请输入码" data-parsley-maxlength="30"
                                       name="code">
                            </div>
                            <div class="col-lg-2">
                                <a href="#" id="searchFama" class="btn btn-primary">
                                    查询
                                </a>
                                <a href="#" id="export" class="btn btn-primary">
                                    导出
                                </a>
                            </div>
                        </div>
                    </div>
                </form>
                <div class="row">
                    <div class="col-lg-12">
                        <section class="panel">
                            <div class="pull-out">
                                <table class="table table-striped m-b-none" data-ride="datatables">
                                    <thead>
                                    <tr>
                                        <th width="10%">订单编号</th>
                                        <th width="8%">企业</th>
                                        <th width="8%">商铺</th>
                                        <th width="15%">门店</th>
                                        <th width="12%">活动名称</th>
                                        <th width="12%">时间</th>
                                        <th width="10%">状态</th>
                                        <th width="15%">码</th>
                                        <th width="15%">设备号</th>
                                        <th width="15%">电话</th>
                                        <th width="15%">验证结果</th>
                                        <th width="15%">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </section>
                    </div>
                </div>
            </div>
        </div>
    </section>
</section>
<script src="common/js/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="common/js/bootstrap.min.js" type="text/javascript"></script>
<script src="common/js/index.js" type="text/javascript"></script>
<!-- 验证 -->
<script src="common/js/parsley/parsley.js" type="text/javascript"></script>
<!-- checkbox -->
<script src="common/js/fuelux/fuelux.js" type="text/javascript"></script>

<!-- datatables -->
<script src="common/js/datatables/jquery.dataTables10.min.js" type="text/javascript"></script>
<script src="common/js/datepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<script src="common/js/datepicker/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
<script src="static/js/bootbox.min.js" type="text/javascript"></script>
<script>
    function GetRequest() {
        var url = decodeURI(location.search); //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            var strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
</script>
<script>
    var Request = GetRequest();
    var activityName = Request["activityName"];
    var storeName = Request["storeName"];
    var storeId = Request["storeId"];
    var activityId = Request["activityId"];
    $("input[name='activityName']").val(activityName);
    $("input[name='storeName']").val(storeName);
    $("input[name='storeId']").val(storeId);
    $("input[name='activityId']").val(activityId);
    var famaTable;
    var page = 1;
    function initTab() {
        famaTable = $('#fama').find('table[data-ride="datatables"]').DataTable({
                    "ajax": {
                        url: "order/queryOrderPage?type=02",
                        data: function (formObject) {
                            //获取表单基本元素对象
                            var formArray = $("#queryOrderPage").serializeArray();
                            //var formObject = new Object();
                            $.each(formArray, function (index) {
                                if (formObject[this['name']]) {
                                    formObject[this['name']] = formObject[this['name']] + "," + this['value'];
                                } else {
                                    formObject[this['name']] = this['value'];
                                }
                            });
                            //获取表单状态
                            var statuses;
                            var checkboxArray = $("#queryOrderPage input:checked");
                            checkboxArray.each(function (i) {
                                if (statuses == null || statuses == '') {
                                    statuses = $(this).val();
                                } else {
                                    statuses += ',' + $(this).val();
                                }
                            });
                            formObject.statuses = statuses;
                            return formObject;
                        },
                        type: "post",
                    },
                    "processing": true,
                    "serverSide": true,
                    "autoWidth": true,
                    "searching": false,
                    "searchDelay": 500,
                    "ordering": false,
                    "lengthChange": false,
                    "displayStart": parseInt(page) * 10 - 10,
                    "pagingType": "full_numbers",
                    "pageLength": 10,
                    "dom": "<'row'<'col col-lg-6'l><'col col-lg-6'f>r>t<'row'<'col col-lg-6'i><'col col-lg-6'p>>",
                    "aaSorting": [[4, "desc"]],//默认排序
                    "columns": [
                        {"data": "orderId", "name": "orderId", "width": "90px"},
                        {"data": "enterpriseName", "name": "enterpriseName", "width": "70px"},
                        {"data": "shopName", "name": "shopName", "width": "70px"},
                        {"data": "storeName", "name": "storeName", "width": "70px"},
                        {"data": "activityName", "name": "activityName", "width": "90px"},
                        {"data": "orderTime", "name": "orderTime", "width": "90px"},
                        {"data": "status", "name": "status", "width": "70px"},
                        {"data": "code", "name": "code", "width": "70px"},
                        {"data": "enCode", "name": "enCode", "width": "70px"},
                        {"data": "mobile", "name": "mobile", "width": "70px"},
                        {"data": "msg", "name": "msg", "width": "70px"},
                        {"data": null, "width": "70px"}
                    ],
                    "columnDefs": [
                        {
                            "targets": 5,
                            "data": "orderTime",
                            "sortable": false,
                            "render": function (data, type, full) {
                                //return new Date(parseInt(data)).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
                                var date = new Date(parseInt(data));
                                return date.format("yyyy-MM-dd hh:mm:ss");
                            }
                        }, {
                            "targets": 6,
                            "data": "status",
                            "sortable": false,
                            "render": function (data, type, full) {
                                var statusText = "";
                                if (data == "0") {
                                    statusText = "消费";
                                }
                                if (data == "2") {
                                    statusText = "撤销";
                                }
                                return statusText;
                            }
                        },
                        {
                            "targets": 11,
                            "data": null,
                            "sortable": false,
                            "render": function (data, type, full) {
                                if (full['status'] == "2") {
                                    return '<a href="#"></a>';
                                }
                                if (full['status'] == "0" && full['verifyStatus'] == "1") {
                                    return '<a href="javascript:doUpdate(this,\'' + full['orderId'] + '\',\'' + full['enCode'] + '\')"data-id="' + full['orderId'] + '">撤消</a>';
                                }
                                return "";
                            }
                        }
                    ]
                }
        );
    }
</script>
<script src="common/js/own/record.js" type="text/javascript"></script>
<script>
    $("#searchFama").click(function () {
        famaTable.ajax.reload();
    });
    $(".datetimepicker").each(function () {
        var $this = $(this);
        $this.datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true,
            language: 'zh-CN',
            todayHighlight: true
        });
    });
    $("#jifenStartTime").datetimepicker().on('hide', function (e) {
        $("#jifenEndTime").datetimepicker('setStartDate', $("#jifenStartTime").val());
    });
    $('#jifenEndTime').datetimepicker().on('hide', function (e) {
        $('#jifenStartTime').datetimepicker('setEndDate', $("#jifenEndTime").val());
    });
    $("#startTime").datetimepicker().on('hide', function (e) {
        $("#endTime").datetimepicker('setStartDate', $("#startTime").val());
    });
    $('#endTime').datetimepicker().on('hide', function (e) {
        $('#startTime').datetimepicker('setEndDate', $("#endTime").val());
    });
</script>
</body>
</html>